package com.lifeng;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @description:
 * @author: lifeng
 * @create: 2020/9/18 13:29
 */
@RestController
public class MsgController {
    @Resource
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("/sendstr")
    public Object sendStr(String name){
        Map<String,Object> msg = new HashMap<>();
        msg.put("userid", UUID.randomUUID().toString());
        msg.put("username",name);
        rocketMQTemplate.convertAndSend("lifeng-topic",msg);
        return msg;
    }
}
